﻿$(function () {

    var l = abp.localization.getResource('Rechargeable');

    var dataTable = $('#PorductTable').DataTable(abp.libs.datatables.normalizeConfiguration({
        ajax: abp.libs.datatables.createAjax(rechargeable.products.product.getList),
        processing: true,
        serverSide: true,
        paging: true,
        searching: false,
        autoWidth: false,
        scrollCollapse: true,
        order: [[1, "desc"]],
        columnDefs: [
            {
                rowAction: {
                    items:
                        [
                            {
                                text: l('ViewProductPrices'),
                                action: function (data) {
                                    window.location.href = abp.appPath + "Products/Prices?productId=" + data.record.id;
                                }
                            }
                        ]
                }
            },
            {data:"id"},
            { data: "name" },
            { data: "gameName" },
            { data: "version" },
            { data: "desc" },
            { data: "creationTime" }
        ]
    }));

    var createModal = new abp.ModalManager(abp.appPath + "Products/CreateModal");
    createModal.onResult(function () {
        dataTable.ajax.reload();
    });
    $("#btnCreate").on("click", function (e) {
        e.preventDefault();
        createModal.open();
    });
});